package com.oneonefive.trainticketsystem.controller;

import com.oneonefive.trainticketsystem.pojo.Sale;
import com.oneonefive.trainticketsystem.service.SaleService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class SaleController {
    final
    SaleService saleService;

    public SaleController(SaleService saleService) {
        this.saleService = saleService;
    }
    @RequestMapping("/deleteSale")
    public boolean delete(Integer saleId){
        return saleService.removeById(saleId);
    }
    @RequestMapping("/insertSale")
    public boolean insertSale(Integer saleId, Integer ticketId, String saleTime,Integer userId){
        return saleService.insertSale(saleId,ticketId,saleTime,userId);
    }
    @RequestMapping("/selectSale")
    public List<Sale> selectSale(Integer saleId, Integer ticketId,Integer userId,Integer page){
        return saleService.selectAllSales(saleId,ticketId,userId,page);
    }
    @RequestMapping("/getSaleRowCount")
    public int getSaleRowCount(Integer saleId, Integer ticketId, String saleTime,Integer userId){
        return saleService.getSaleRowCount(saleId,ticketId,saleTime,userId);
    }
}
